<?php
/**
 * +----------------------------------------------------------------------
 * | 表单验证器
 * +----------------------------------------------------------------------
 *                      _ooOoo_
 *                     o8888888o            | AUTHOR: 杜云
 *                     88" . "88            | EMAIL: 987772927@qq.com
 *                     (| -_- |)            | QQ: 987772927
 *                     O\  =  /O            | WECHAT: 987772927
 *                  ____/`---'\____
 *                .'  \\|     |//  `.
 *               /  \\|||  :  |||//  \
 *              /  _||||| -:- |||||-  \
 *              |   | \\\  -  /// |   |
 *              | \_|  ''\-/''  |   |
 *              \  .-\__  `-`  ___/-. /
 *            ___`. .'  /-.-\  `. . __
 *         ."" '<  `.___\_<|>_/___.'  >'"".
 *        | | :  `- \`.;`\ _ /`;.`/ - ` : | |
 *        \  \ `-.   \_ __\ /__ _/   .-` /  /
 *   ======`-.____`-.___\_____/___.-`____.-'======
 *                      `=-='
 * +----------------------------------------------------------------------
 */
declare(strict_types=1);
namespace App\Request;

use Hyperf\Validation\Request\FormRequest;
use Hyperf\Validation\Rule;
class VehicleApplicationRequest extends FormRequest
{

    public function authorize(): bool
    {
        return true;
    }
    public function rules(): array
    {
        return [
            'id' => ['required'],
            // 'mid' => ['required'],
            'user' => 'required|max:500',
            'case_no' => 'required',
            'people_number' => 'required|numeric|min:1|max:100',
            'start_time' => 'required|date',
            'end_time' => 'required|date',
            'application_number' => 'required|numeric|min:1|max:100',
            'dispatching_unit' => 'required',
            'destination' => 'required|max:255',
            'lng' => 'required',
            'lat' => 'required',
            'purpose' => 'required|max:1000',
            'is_back' => 'required|numeric',
        ];
    }
    public function attributes(): array
    {
        return [
            // 'mid' => '机构id',
            'user' => '使用人',
            'case_no' => '案号',
            'people_number' => '乘车人数',
            'start_time' => '开始时间',
            'end_time' => '结束时间',
            'application_number' => '申请数量',
            'dispatching_unit' => '派车单位',
            'destination' => '目的地',
            'lng' => '目的地经度',
            'lat' => '目的地纬度',
            'purpose' => '用途',
            'is_back' => '撤回'
        ];
    }
    public function messages(): array
    {
        return [
            'is_back.required' => '申请撤回失败',
            'is_back.numeric' => '申请撤回失败',
            'lng.required' => '目的地选择有误',
            'lng.decimal' => '目的地选择有误',
            'lat.required' => '目的地选择有误',
            'lat.decimal' => '目的地选择有误',
        ];
    }
    protected $scenes = [
        'add' => ['user','case_no','people_number','start_time','end_time','application_number','destination','purpose'],
        'edit' => ['id','user','case_no','people_number','start_time','end_time','application_number','destination','purpose'],
        'back' => ['id'],
    ];
}
